﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGePoint3d : IDisposable
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGePoint3d(IntPtr cPtr, bool cMemoryOwn)
		{
			this.swigCMemOwn = cMemoryOwn;
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGePoint3d obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGePoint3d()
		{
			this.Dispose();
		}

		public virtual void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGePoint3d(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
		}

		public static OdGePoint3d operator +(OdGePoint3d p, OdGeVector3d v)
		{
			return p.Add(v);
		}

		public static OdGePoint3d operator -(OdGePoint3d p, OdGeVector3d v)
		{
			return p.Sub(v);
		}

		public static OdGeVector3d operator -(OdGePoint3d p, OdGePoint3d v)
		{
			return p.Sub(v);
		}

		public static OdGePoint3d operator *(OdGePoint3d v, double d)
		{
			return v.Mul(d);
		}

		public override string ToString()
		{
			if (this.swigCPtr.Handle == IntPtr.Zero)
			{
				return "Empty";
			}
			return string.Format("({0},{1},{2})", this.x, this.y, this.z);
		}

		public OdGePoint3d() : this(GlobalsPINVOKE.new_OdGePoint3d__SWIG_0(), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGePoint3d(OdGePoint3d source) : this(GlobalsPINVOKE.new_OdGePoint3d__SWIG_1(OdGePoint3d.getCPtr(source)), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGePoint3d(double xx, double yy, double zz) : this(GlobalsPINVOKE.new_OdGePoint3d__SWIG_2(xx, yy, zz), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGePoint3d(OdGePlanarEnt plane, OdGePoint2d pnt2d) : this(GlobalsPINVOKE.new_OdGePoint3d__SWIG_3(OdGePlanarEnt.getCPtr(plane), OdGePoint2d.getCPtr(pnt2d)), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public static OdGePoint3d kOrigin
		{
			get
			{
				IntPtr intPtr = GlobalsPINVOKE.OdGePoint3d_kOrigin_get();
				OdGePoint3d result = (intPtr == IntPtr.Zero) ? null : new OdGePoint3d(intPtr, false);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
		}

		public OdGePoint3d setToProduct(OdGeMatrix3d xfm, OdGePoint3d point)
		{
			GlobalsPINVOKE.OdGePoint3d_setToProduct(this.swigCPtr, OdGeMatrix3d.getCPtr(xfm), OdGePoint3d.getCPtr(point));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return new OdGePoint3d(this);
		}

		public OdGePoint3d transformBy(OdGeMatrix3d xfm)
		{
			GlobalsPINVOKE.OdGePoint3d_transformBy(this.swigCPtr, OdGeMatrix3d.getCPtr(xfm));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return new OdGePoint3d(this);
		}

		public OdGePoint3d rotateBy(double angle, OdGeVector3d vect, OdGePoint3d basePoint)
		{
			GlobalsPINVOKE.OdGePoint3d_rotateBy__SWIG_0(this.swigCPtr, angle, OdGeVector3d.getCPtr(vect), OdGePoint3d.getCPtr(basePoint));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return new OdGePoint3d(this);
		}

		public OdGePoint3d rotateBy(double angle, OdGeVector3d vect)
		{
			GlobalsPINVOKE.OdGePoint3d_rotateBy__SWIG_1(this.swigCPtr, angle, OdGeVector3d.getCPtr(vect));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return new OdGePoint3d(this);
		}

		public OdGePoint3d mirror(OdGePlane plane)
		{
			GlobalsPINVOKE.OdGePoint3d_mirror(this.swigCPtr, OdGePlane.getCPtr(plane));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return new OdGePoint3d(this);
		}

		public OdGePoint3d scaleBy(double scaleFactor, OdGePoint3d basePoint)
		{
			OdGePoint3d result = new OdGePoint3d(GlobalsPINVOKE.OdGePoint3d_scaleBy__SWIG_0(this.swigCPtr, scaleFactor, OdGePoint3d.getCPtr(basePoint)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint3d scaleBy(double scaleFactor)
		{
			OdGePoint3d result = new OdGePoint3d(GlobalsPINVOKE.OdGePoint3d_scaleBy__SWIG_1(this.swigCPtr, scaleFactor), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint2d convert2d(OdGePlanarEnt plane)
		{
			OdGePoint2d result = new OdGePoint2d(GlobalsPINVOKE.OdGePoint3d_convert2d__SWIG_0(this.swigCPtr, OdGePlanarEnt.getCPtr(plane)), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint2d convert2d()
		{
			OdGePoint2d result = new OdGePoint2d(GlobalsPINVOKE.OdGePoint3d_convert2d__SWIG_1(this.swigCPtr), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint3d Mul(double scale)
		{
			OdGePoint3d result = new OdGePoint3d(GlobalsPINVOKE.OdGePoint3d_Mul__SWIG_0(this.swigCPtr, scale), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint3d Div(double scale)
		{
			OdGePoint3d result = new OdGePoint3d(GlobalsPINVOKE.OdGePoint3d_Div__SWIG_0(this.swigCPtr, scale), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint3d Add(OdGeVector3d vect)
		{
			OdGePoint3d result = new OdGePoint3d(GlobalsPINVOKE.OdGePoint3d_Add__SWIG_0(this.swigCPtr, OdGeVector3d.getCPtr(vect)), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint3d Sub(OdGeVector3d vect)
		{
			OdGePoint3d result = new OdGePoint3d(GlobalsPINVOKE.OdGePoint3d_Sub__SWIG_0(this.swigCPtr, OdGeVector3d.getCPtr(vect)), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint3d setToSum(OdGePoint3d point, OdGeVector3d vect)
		{
			GlobalsPINVOKE.OdGePoint3d_setToSum(this.swigCPtr, OdGePoint3d.getCPtr(point), OdGeVector3d.getCPtr(vect));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return new OdGePoint3d(this);
		}

		public OdGeVector3d Sub(OdGePoint3d point)
		{
			OdGeVector3d result = new OdGeVector3d(GlobalsPINVOKE.OdGePoint3d_Sub__SWIG_2(this.swigCPtr, OdGePoint3d.getCPtr(point)), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGeVector3d asVector()
		{
			OdGeVector3d result = new OdGeVector3d(GlobalsPINVOKE.OdGePoint3d_asVector(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public double distanceTo(OdGePoint3d point)
		{
			double result = GlobalsPINVOKE.OdGePoint3d_distanceTo(this.swigCPtr, OdGePoint3d.getCPtr(point));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint3d project(OdGePlane plane, OdGeVector3d vect)
		{
			OdGePoint3d result = new OdGePoint3d(GlobalsPINVOKE.OdGePoint3d_project(this.swigCPtr, OdGePlane.getCPtr(plane), OdGeVector3d.getCPtr(vect)), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint3d orthoProject(OdGePlane plane)
		{
			OdGePoint3d result = new OdGePoint3d(GlobalsPINVOKE.OdGePoint3d_orthoProject(this.swigCPtr, OdGePlane.getCPtr(plane)), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool IsEqual(OdGePoint3d point)
		{
			bool result = GlobalsPINVOKE.OdGePoint3d_IsEqual(this.swigCPtr, OdGePoint3d.getCPtr(point));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool IsNotEqual(OdGePoint3d point)
		{
			bool result = GlobalsPINVOKE.OdGePoint3d_IsNotEqual(this.swigCPtr, OdGePoint3d.getCPtr(point));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isEqualTo(OdGePoint3d point, OdGeTol tol)
		{
			bool result = GlobalsPINVOKE.OdGePoint3d_isEqualTo__SWIG_0(this.swigCPtr, OdGePoint3d.getCPtr(point), OdGeTol.getCPtr(tol));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isEqualTo(OdGePoint3d point)
		{
			bool result = GlobalsPINVOKE.OdGePoint3d_isEqualTo__SWIG_1(this.swigCPtr, OdGePoint3d.getCPtr(point));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public double GetItem(uint i)
		{
			double result = GlobalsPINVOKE.OdGePoint3d_GetItem__SWIG_0(this.swigCPtr, i);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint3d set(double xx, double yy, double zz)
		{
			GlobalsPINVOKE.OdGePoint3d_set__SWIG_0(this.swigCPtr, xx, yy, zz);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return new OdGePoint3d(this);
		}

		public OdGePoint3d set(OdGePlanarEnt plane, OdGePoint2d point)
		{
			GlobalsPINVOKE.OdGePoint3d_set__SWIG_1(this.swigCPtr, OdGePlanarEnt.getCPtr(plane), OdGePoint2d.getCPtr(point));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return new OdGePoint3d(this);
		}

		public double x
		{
			get
			{
				double result = GlobalsPINVOKE.OdGePoint3d_x_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.OdGePoint3d_x_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public double y
		{
			get
			{
				double result = GlobalsPINVOKE.OdGePoint3d_y_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.OdGePoint3d_y_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public double z
		{
			get
			{
				double result = GlobalsPINVOKE.OdGePoint3d_z_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.OdGePoint3d_z_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		protected bool swigCMemOwn;
	}
}
